package com.petshop.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class ShowTimeServlet extends HttpServlet{

	Date initTime;
	public void init() throws ServletException {
	super.init();
	System.out.println("ShowTimeServet is initial");
	initTime = new Date();
	
	}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		
		System.out.println("Session Die > "+session.getMaxInactiveInterval());
		session.setMaxInactiveInterval(20);
		System.out.println("Session start > "+initTime.getSeconds());
		
		PrintWriter out = response.getWriter();
		out.print("<html><H2>Initial Time is : </H2><br/></html>");
		out.print( initTime );
		out.print("<html><H2>Current Time is : </H2><br/></html>");
		out.print( new Date() );
	}
	
	public void destroy() {
		System.out.println("ShowTimeServet is destroyed");
		super.destroy();
	}


	
}
